home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / desaware / stgtools / reg_demo / findvalu.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-03-22  |  6.5 KB  |  217 lines

  1. VERSION 4.00
  2. Begin VB.Form FindValue 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Find Value"
  5.    ClientHeight    =   3525
  6.    ClientLeft      =   2430
  7.    ClientTop       =   1590
  8.    ClientWidth     =   4995
  9.    ClipControls    =   0   'False
  10.    Height          =   3990
  11.    Left            =   2340
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3525
  14.    ScaleWidth      =   4995
  15.    Top             =   1215
  16.    Width           =   5175
  17.    Begin VB.CheckBox ChkWhole 
  18.       Caption         =   "Match to Whole Value Only"
  19.       Height          =   255
  20.       Left            =   1320
  21.       TabIndex        =   10
  22.       Top             =   1560
  23.       Width           =   2295
  24.    End
  25.    Begin VB.Frame Frame3 
  26.       Caption         =   "Data to Search For"
  27.       Height          =   735
  28.       Left            =   120
  29.       TabIndex        =   7
  30.       Top             =   600
  31.       Width           =   4695
  32.       Begin VB.TextBox DataView 
  33.          BackColor       =   &H00C0C0C0&
  34.          Enabled         =   0   'False
  35.          Height          =   315
  36.          Left            =   120
  37.          TabIndex        =   9
  38.          Top             =   270
  39.          Width           =   3015
  40.       End
  41.       Begin VB.CommandButton ButtonChange 
  42.          Caption         =   "Change Data"
  43.          Height          =   375
  44.          Left            =   3240
  45.          TabIndex        =   8
  46.          Top             =   240
  47.          Width           =   1335
  48.       End
  49.    End
  50.    Begin VB.CommandButton ButtonCancel 
  51.       Caption         =   "Close"
  52.       Height          =   375
  53.       Left            =   2280
  54.       TabIndex        =   6
  55.       Top             =   3000
  56.       Width           =   1215
  57.    End
  58.    Begin VB.CommandButton ButtonStart 
  59.       Caption         =   "Find"
  60.       Height          =   375
  61.       Left            =   3600
  62.       TabIndex        =   5
  63.       Top             =   3000
  64.       Width           =   1215
  65.    End
  66.    Begin VB.Frame Frame2 
  67.       Caption         =   "Search Area"
  68.       ClipControls    =   0   'False
  69.       Height          =   615
  70.       Left            =   120
  71.       TabIndex        =   2
  72.       Top             =   2040
  73.       Width           =   4695
  74.       Begin VB.OptionButton OptCurrent 
  75.          Caption         =   "Start Search at Current Key"
  76.          Height          =   255
  77.          Left            =   2280
  78.          TabIndex        =   4
  79.          Top             =   240
  80.          Value           =   -1  'True
  81.          Width           =   2295
  82.       End
  83.       Begin VB.OptionButton OptRoot 
  84.          Caption         =   "Start Search at Root"
  85.          Height          =   255
  86.          Left            =   240
  87.          TabIndex        =   3
  88.          Top             =   240
  89.          Width           =   1935
  90.       End
  91.    End
  92.    Begin VB.ComboBox ComboType 
  93.       Height          =   300
  94.       ItemData        =   "FINDVALU.frx":0000
  95.       Left            =   1440
  96.       List            =   "FINDVALU.frx":0016
  97.       Style           =   2  'Dropdown List
  98.       TabIndex        =   0
  99.       Top             =   120
  100.       Width           =   3495
  101.    End
  102.    Begin VB.Label Label2 
  103.       BackStyle       =   0  'Transparent
  104.       Caption         =   "Data Type:"
  105.       Height          =   255
  106.       Left            =   120
  107.       TabIndex        =   1
  108.       Top             =   120
  109.       Width           =   1215
  110.    End
  111. Attribute VB_Name = "FindValue"
  112. Attribute VB_Creatable = False
  113. Attribute VB_Exposed = False
  114. Option Explicit
  115. Dim Data As Variant
  116. Dim DataType As Long
  117. Dim DataSize As Long
  118. ' Close Button.  Unloads the dialog box.
  119. Private Sub ButtonCancel_Click()
  120.     Unload FindValue
  121. End Sub
  122. ' Change Data Button.  This brings up a dialog box
  123. ' that allows the user to edit what data to look
  124. ' for.
  125. Private Sub ButtonChange_Click()
  126.     Const MaxBytes = 12
  127.     Dim i As Integer
  128.     Dim ending As Integer
  129.     Dim ltr As String
  130.     Select Case ComboType.ListIndex
  131.     Case 0
  132.         DataType = Reg_SZ
  133. #If Win32 Then
  134.     Case 1
  135.         DataType = Reg_Expand_SZ
  136.     Case 2
  137.         DataType = Reg_Multi_SZ
  138.     Case 3
  139.         DataType = Reg_Dword
  140.     Case 4
  141.         DataType = Reg_Dword_Big_Endian
  142.     Case 5
  143.         DataType = Reg_Binary
  144. #End If
  145.     End Select
  146.         
  147.     GlobalValueName = ""
  148.     GlobalValueVariant = Data
  149.     GlobalValueSize = Len(Data)
  150.     GlobalValueType = DataType
  151.     GlobalValueChanged = False
  152.     Select Case GlobalValueType
  153.     Case Reg_None
  154.         Load StringEdit
  155.         StringEdit.Show vbModal
  156.     Case Reg_SZ
  157.         Load StringEdit
  158.         StringEdit.Show vbModal
  159.     End Select
  160.     If GlobalValueChanged = False Then
  161.         Exit Sub
  162.     End If
  163.     Data = GlobalValueVariant
  164.     DataSize = GlobalValueSize
  165.     DataView.Text = ""
  166.     ' This trims binary/string data to the size of the
  167.     ' edit box.
  168.     If (DataSize > MaxBytes) Then ending = MaxBytes Else ending = DataSize
  169.     For i = 1 To ending
  170.         ltr = Mid(Data, i, 1)
  171.         DataView.Text = DataView.Text & ltr
  172.     Next i
  173.     If (ending = MaxBytes) Then
  174.         DataView.Text = DataView.Text & "..."
  175.     End If
  176. End Sub
  177. ' Find Button.  This finds all the keys and values
  178. ' that match, and puts them into another form.
  179. Private Sub ButtonStart_Click()
  180.     Dim whole As Boolean
  181.     Dim AtRoot As Boolean
  182.     Dim RetVal As Boolean
  183.     whole = ChkWhole.Value
  184.     AtRoot = OptRoot.Value
  185.     FindValue.MousePointer = 11
  186.     RetVal = BaseForm.Registry1.FindFirstValue(Data, DataType, DataSize, whole, AtRoot)
  187.     If RetVal = False Then
  188.         MsgBox ("There are no values in this area that match.")
  189.         FindValue.MousePointer = 0
  190.         Exit Sub
  191.     End If
  192.     FindValue.MousePointer = 0
  193.     FindResults.listresults.Clear
  194.     Do
  195.         FindResults.listresults.AddItem "KEY: " & BaseForm.Registry1.FindResultKey
  196. #If Win32 Then
  197.         FindResults.listresults.AddItem "VALUE NAME: " & BaseForm.Registry1.FindResultValueName
  198.         FindResults.listresults.AddItem ""
  199. #End If
  200.     Loop While BaseForm.Registry1.FindNextValue() = True
  201.     FindResults.Show
  202.     Exit Sub
  203. End Sub
  204. Private Sub ComboType_Change()
  205. Data = Empty
  206. DataSize = 0
  207. End Sub
  208. ' Make sure the (preloaded) combobox that shows the
  209. ' type of data to look for shows the first element
  210. ' in the list.
  211. Private Sub Form_Load()
  212.     ComboType.ListIndex = 0
  213.     ' In this key, there is only one choice. (REG_SZ)
  214.     ComboType.Enabled = False
  215.     DataView.Text = Data
  216. End Sub
  217.